package com.kxf.rpc.registry;

import com.kxf.rpc.enumeration.RpcError;
import com.kxf.rpc.exception.RpcException;
import com.kxf.rpc.registry.redis.RedisServiceRegistry;

import java.net.InetSocketAddress;

/**
 * @author Kxf
 * @create 2021/9/23,0023 15:08
 */
public interface ServiceRegistry {

    void registry(String interfaceName, InetSocketAddress address);

    static ServiceRegistry getByCode(int code) {
        switch (code) {
            case 0:
                return new RedisServiceRegistry();
            default:
                throw new RpcException(RpcError.REGISTRY_NOT_FIND);
        }
    }
}
